#include <iostream>

using namespace std;

bool palin(int k)
{
    short a[100];
    int i=0, j;
    while (k > 0)
    {
        a[i] = k % 10;
        k /= 10;
        i++;
    }
    i--;
    j = 0;
    while (j <= i)
    {
        if (a[i] == a[j]) 
        {
            i--;
            j++;
        }
        else break;     
    }
    return (j > i);    
}

int main()
{
    int res = -1;
    for (int i = 999; i >= 100; i--)
        for (int j = i; j >= 100; j--)
            if (palin(i*j) && (i*j > res)) res = i*j;
    cout << res << endl;
//    getchar();
    return 0;
}
